package com.qidian.mes.defect.controller;

import com.qidian.mes.defect.service.MaterialService;
import com.qidianit.common.pojo.MESResult;
import com.qidianit.mes.pojo.DetectName;
import com.qidianit.mes.pojo.MaterialDetect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 泽华
 * @Description
 * @Time 2024-10-23 0:36
 */
@RestController
@CrossOrigin
@RequestMapping("/materialItem")

public class MaterialController {
    @Autowired
    private MaterialService materialService;
    @GetMapping("/list")
    public MESResult list(String materialId,
                          String materialName,
                          String model,
                          Long testLow,
                          String unit,
                          String numberTop,
                          Long fatal,
                          Long severe,
                          Long slight,
                          @RequestParam(defaultValue = "1")int page,
                          @RequestParam(defaultValue = "10") int limit){
        return materialService.list(
                materialId,
                materialName,
                model,
                testLow,
                unit,
                numberTop,
                fatal,
                severe,
                slight,
                page,
                limit);
    }

    @PostMapping("/save")
    public MESResult save(@RequestBody MaterialDetect materialDetect){
        return materialService.save(materialDetect);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody MaterialDetect materialDetect){
        return materialService.update(materialDetect);
    }

    //通过id查询这条数据
    @GetMapping("/get")
    public MESResult get(String materialId){
        return materialService.selectById(materialId);
    }



}
